<html>
<head><meta charset="utf-8"><title>Virtual locals scheme compiler-team#291 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html">Virtual locals scheme compiler-team#291</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196928356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/196928356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#196928356">(May 08 2020 at 17:52)</a>:</h4>
<p>A new proposal has been announced <a href="https://github.com/rust-lang/compiler-team/issues/291" title="https://github.com/rust-lang/compiler-team/issues/291">#291</a>. It will be brought up at the next meeting.</p>



<a name="196930073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/196930073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#196930073">(May 08 2020 at 18:05)</a>:</h4>
<p>The "this HackMD" link links to the issue</p>



<a name="196931926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/196931926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#196931926">(May 08 2020 at 18:21)</a>:</h4>
<p>fixed</p>



<a name="197239317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197239317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197239317">(May 12 2020 at 07:01)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="492">@T-compiler</span>: Proposal <a href="https://github.com/rust-lang/compiler-team/issues/291#issuecomment-627153189">#291</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="197252016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197252016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197252016">(May 12 2020 at 09:35)</a>:</h4>
<p>I'm curious to get <span class="user-mention" data-user-id="120791">@RalfJ</span>'s opinion on this scheme. I can't remember how much he and I have talked about it.</p>



<a name="197252039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197252039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197252039">(May 12 2020 at 09:35)</a>:</h4>
<p>It's sort of the first 'major' change to MIR since it's initial design</p>



<a name="197329993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197329993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197329993">(May 12 2020 at 19:58)</a>:</h4>
<p>so where do I find the details of the proposal? the issue linked here seems to only scratch the surface?</p>



<a name="197330085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330085">(May 12 2020 at 19:59)</a>:</h4>
<p>in particular, what exactly would<code>Rvalue</code> (<code>Value</code>?) and <code>Place</code> look like after this change?</p>



<a name="197330173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330173">(May 12 2020 at 19:59)</a>:</h4>
<p>oh its that hackmd... the text sounds like that would describe the grand plan and not just this one change</p>



<a name="197330600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330600">(May 12 2020 at 20:02)</a>:</h4>
<p>hm okay that hackmd unfortunately also doesnt show what exactly the enums would look like... but it contains more details so that's nice :D</p>



<a name="197330659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330659">(May 12 2020 at 20:03)</a>:</h4>
<p>this sounds almost like some kind "first-class places" to me, which seems nice :D though it only goes part of the way, I am still trying to figure out what exactly the limitations are</p>



<a name="197330838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330838">(May 12 2020 at 20:05)</a>:</h4>
<p>but I am not sure I agree with this:</p>
<blockquote>
<p>miri: trivial, we just treat the special locals as real locals of pointer to actual type instead of the actual type. Each StatementKind::Project just behaves like StatementKind::Assign with an Rvalue::Ref.</p>
</blockquote>
<p>so first of all, I presume this should be <code>Rvalue::AddressOf</code>, because we certainly dont want reborrowing. (so, no <code>Retag</code> emitted for these.)<br>
but secondly... a place is not isomorphic to a pointer. maybe it should be, I am not sure, but in Miri places also track the expected alignment, unlike pointers where the expected alignment is given by the type. and indeed I think the proposed scheme would break field access to packed structs.</p>



<a name="197330926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197330926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197330926">(May 12 2020 at 20:06)</a>:</h4>
<p>if this is truly "first-class places", then miri should properly support "place variables" by storing a <code>Place</code> (<code>PlaceTy</code>? but seems odd to keep the layout) inside them.</p>



<a name="197331491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197331491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197331491">(May 12 2020 at 20:10)</a>:</h4>
<p>which brings me to my main question:</p>
<blockquote>
<p>Thus, we propose to add virtual locals that don’t actually have any own memory, but which are temporary variables for storing places.</p>
</blockquote>
<p>so can I imagine this like, there are now two kinds of locals, I'll call them "value locals"  (that we already have, they store <a href="https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#value">values</a>) and the new "place locals" which store <a href="https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#place">places</a>? Can the same variable be used in both <code>StatementKind::Project</code> and <code>StatementKind::Assign</code>? (I would think not.)<br>
Also <code>Project</code> is not a great name IMO, the projection is happening on the RHS, this is really just a normal assignment of a place to a place local... as opposed to a value local which gets assigned a value (hence the RHS of an <code>Assign</code> is <code>Value</code>, but the RHS of... <code>AssignPlace</code>?... is <code>Place</code> I presume, but the hachmd doesnt spell out the types)</p>



<a name="197340790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197340790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197340790">(May 12 2020 at 21:17)</a>:</h4>
<p>Good questions. I agree we should extend the proposal with more details. Part of the reason I know this is true is that I don't know which answers I think are best just yet. :)</p>



<a name="197382866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197382866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197382866">(May 13 2020 at 08:42)</a>:</h4>
<p>is there some place I could write something more coherent than this stream-of-thoughts? the issue you linked says it is not for discussion... so what <em>is</em> for discussion?^^ It mentions Zulip, which is nice but not good for leaving deeply thought-out comments in my experience.</p>



<a name="197382925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197382925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197382925">(May 13 2020 at 08:43)</a>:</h4>
<p>also FWIW I was rather confused by the first half of the linked issue as it seems to have nothing to do with the actual proposal, it's all meta stuff. I made a best guess at where the meta stuff ends without wanting to read it all in detail, I hope I got that right...</p>



<a name="197382965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197382965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197382965">(May 13 2020 at 08:43)</a>:</h4>
<p>from the perspective of someone asked for feedback on the proposal, more than 2/3 of that post is noise that has nothing to do with the actual proposal. Things like "If your change is proposing a new stable feature, such as a -C flag, [...]" look as if they were accidentally left in from a template, though maybe that was on purpose? I assume "you" here is "author of the MCP" not "reader of the MCP", but that's not at all clear until mid-way through the sentence... usually when I read an issue and it says "you" I would assume that addresses all readers of the issue.</p>



<a name="197383064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197383064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197383064">(May 13 2020 at 08:45)</a>:</h4>
<blockquote>
<p>This is work towards the eventual goal of removing entirely PlaceElem::Index. You can see the full proposal in this HackMD.</p>
</blockquote>
<p>now I still dont know if the MCP is for the "eventual goal" or the "full proposal" or something else entirely.</p>



<a name="197383201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197383201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197383201">(May 13 2020 at 08:47)</a>:</h4>
<p>(I understand this MCP stuff is new so consider this feedback on the parts of the process that maybe could use some polishing ;) )</p>



<a name="197387448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197387448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197387448">(May 13 2020 at 09:28)</a>:</h4>
<p>On a different note, I have some concerns about the potential impact of this change on memory usage and compile time, both in general and in particular for codegen (both LLVM and Cranelift).</p>
<p>IIUC, this change would increase the number of statements in most MIR bodies significantly. In return it would shrink <code>Place</code>, but this won't shrink <code>Statement</code> (since <code>StatementKind</code> currently boxes all places), and the <code>PlaceElem</code>s won't go away -- on the contrary, they are no longer interned, and each of them turns into a full <code>Statement</code> that has additional overhead. So I expect a significant increase in memory consumption. More statements also mean more work for essentially all MIR passes, even those who just ignore those statements.</p>
<p>And for codegen, the HackMD outlines two options for how places might get handled after this change:</p>
<ul>
<li>Require "place temporaries" to be used only in the basic block where they're required, and let codegen scan the BB when a place is actually needed for a "real" operation. This seems potentially very inefficient in large basic blocks (which are rare, but still cause huge regressions when algorithms are quadratic or cubic in the size of the BB). It also seems like an annoying extra invariant to uphold while performing MIR transformations.</li>
<li>Codegen the projections as assignments to virtual locals are encountered. This requires extra data structures that weren't needed before, probably not enormous but still. Even if you impose the invariant that these virtual locals are BB-local (again, seems like a potential headache), large basic blocks do exist. But, on the bright side, it has the potential to reduce IR bloat from repeating the same projection over and over, assuming we add a MIR optimization that merges identical virtual locals.</li>
</ul>
<p>None of this is necessarily a blocking concern, but IMO it should be considered carefully before moving forward. For example, I could imagine that it might be a good trade-off to keep the <code>List&lt;PlaceElem&gt;</code> representation for "static" projections and just split out the problematic kinds (deref, variable index).</p>



<a name="197387644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197387644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197387644">(May 13 2020 at 09:30)</a>:</h4>
<p>Yeah, especially for unsized places this would be a regression in cg_clif, as it always stores fat pointers on the stack, rather than in two registers.</p>



<a name="197453061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197453061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197453061">(May 13 2020 at 18:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> Could you say a bit more about what this change is designed to achieve?</p>
<p>I don't think that <a href="https://github.com/rust-lang/rust/issues/71265">#71265</a> is enough to justify what would be a fairly major change. <code>ProjectionElem::Index</code> is pretty low on the list of potential footguns in the MIR, since it is handled automatically for anyone using the <code>Visitor</code> API. Personally, I'm more concerned about <code>Deref</code> projections, since unlike all other projections they refer to memory outside the base local of the <code>Place</code>. It seems quite easy for the various MIR transformations to overlook this, and there's no simple solution like "just use  <code>Visitor::visit_local</code>".</p>
<p>That said, I think we should avoid changes of this scale unless there is something concrete to be gained, like enabling new optimizations or fixing soundness holes. The churn is not worth it otherwise, since we have built quite a few things on top of the existing system.</p>



<a name="197454058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197454058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197454058">(May 13 2020 at 18:13)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> I totally understand the concerns stated here but I think <span class="user-mention" data-user-id="124288">@oli</span>, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> and probably <span class="user-mention" data-user-id="119009">@eddyb</span> have way better understanding than myself to properly justify this</p>



<a name="197461253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461253">(May 13 2020 at 19:08)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> this scheme can handle both indices and deref projections, that's the main appeal</p>



<a name="197461309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461309">(May 13 2020 at 19:08)</a>:</h4>
<p>basically it allows us to build up arbitrarily complex places</p>



<a name="197461359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461359">(May 13 2020 at 19:08)</a>:</h4>
<p>with only "gep-like" places permitted within a single statement</p>



<a name="197461378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461378">(May 13 2020 at 19:08)</a>:</h4>
<p>the entire reason to do this is to make it easier to write optimizations</p>



<a name="197461395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461395">(May 13 2020 at 19:08)</a>:</h4>
<p>it makes the borrow checker harder :)</p>



<a name="197461422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461422">(May 13 2020 at 19:08)</a>:</h4>
<p>I think there is a valid alternative btw</p>



<a name="197461452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461452">(May 13 2020 at 19:09)</a>:</h4>
<p>in which we keep places just how they are today but we "lower" them to remove derefs and stuff and introduce temporaries</p>



<a name="197461672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461672">(May 13 2020 at 19:10)</a>:</h4>
<p>That last suggestion seems much more manageable.</p>



<a name="197461680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461680">(May 13 2020 at 19:10)</a>:</h4>
<p>i.e., if we had</p>
<div class="codehilite"><pre><span></span><code>let x = foo((*tmp[n]).f.g)
</code></pre></div>


<p>it might get converted to</p>
<div class="codehilite"><pre><span></span><code>let tmp = &amp;raw *tmp[n]
let x = foo((*tmp).f.g)
</code></pre></div>


<p>or whatever, idk</p>



<a name="197461710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461710">(May 13 2020 at 19:11)</a>:</h4>
<p>this further digs in on the idea of two phases in the MIR</p>



<a name="197461731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461731">(May 13 2020 at 19:11)</a>:</h4>
<p>the "analyzable" phase and the "optimization" phase</p>



<a name="197461747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461747">(May 13 2020 at 19:11)</a>:</h4>
<p>I was concerned about possible interactions with stacked borrows</p>



<a name="197461788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461788">(May 13 2020 at 19:11)</a>:</h4>
<p>i.e., creating raw pointers has a certain amount of "side effects"</p>



<a name="197461846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461846">(May 13 2020 at 19:12)</a>:</h4>
<p>makes things legal that wouldn't have been legal if something had never had a raw pointer created</p>



<a name="197461880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461880">(May 13 2020 at 19:12)</a>:</h4>
<p>so maybe the answer is that we lower not to <code>&amp;raw</code> but to safe borrows</p>



<a name="197461892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461892">(May 13 2020 at 19:12)</a>:</h4>
<p>which I think for <em>stacked borrows</em> is fine</p>



<a name="197461901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197461901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197461901">(May 13 2020 at 19:12)</a>:</h4>
<p>but which creates problems for <em>borrow check</em></p>



<a name="197462636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197462636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197462636">(May 13 2020 at 19:18)</a>:</h4>
<p>Okay, I'm less worried about churn now. Retrofitting the borrow checker seemed pretty daunting to me. I guess I still share some concerns with <span class="user-mention silent" data-user-id="124289">Hanna Kruppe</span> and <span class="user-mention silent" data-user-id="133247">bjorn3</span> about the additional intermediate values making optimizations/codegen run slower.</p>



<a name="197464337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197464337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197464337">(May 13 2020 at 19:30)</a>:</h4>
<p>Would introducing a SROA pass somewhere in the optimization pipeline solve some of the same problems as this proposal? That might be even more difficult, however.</p>



<a name="197464418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197464418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197464418">(May 13 2020 at 19:31)</a>:</h4>
<p>I can't speak to the concerns around stacked borrows unfortunately.</p>



<a name="197512566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197512566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197512566">(May 14 2020 at 07:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197461901">said</a>:</p>
<blockquote>
<p>but which creates problems for <em>borrow check</em></p>
</blockquote>
<p>I thought this transformation was supposed to happen after analyses, so after borrow checking. In that case this wouldn't be a problem, right?</p>



<a name="197522468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197522468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197522468">(May 14 2020 at 08:20)</a>:</h4>
<p>That's not what the MCP in its current form proposes. It's a conceivable alternative, but not what that hackmd details.</p>



<a name="197529375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197529375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197529375">(May 14 2020 at 09:33)</a>:</h4>
<p>I was talking about the proposed altenrative by niko/ecstatic-morse, which is not to do the virtual locals thing but just "normalize" all projections to make deref projections only ever be the last projection in a chain, and never have multiple deref projections in a projection list</p>



<a name="197559055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197559055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197559055">(May 14 2020 at 14:08)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> if we apply the transformation as a lowering step (as <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> and I were discussing) then indeed borrow check is not impacted</p>



<a name="197559092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197559092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197559092">(May 14 2020 at 14:08)</a>:</h4>
<p>that's kind of the point :)</p>



<a name="197559217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197559217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197559217">(May 14 2020 at 14:08)</a>:</h4>
<p>we can either do this during MIR construction, in which case we have to account for borrow check, or as a later lowering step, in which case we don't</p>



<a name="197559352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197559352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197559352">(May 14 2020 at 14:08)</a>:</h4>
<p>I think I lean towards the latter option but I think the concern was compilation times</p>



<a name="197561595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197561595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197561595">(May 14 2020 at 14:17)</a>:</h4>
<p>it's easy to benchmark such a transformation or even have it behind a flag at first, so I like that option</p>



<a name="197564248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197564248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197564248">(May 14 2020 at 14:37)</a>:</h4>
<p>I think we should close this proposal</p>



<a name="197564262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197564262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197564262">(May 14 2020 at 14:37)</a>:</h4>
<p>and write up a fresh one with the new approach</p>



<a name="197564482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197564482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197564482">(May 14 2020 at 14:39)</a>:</h4>
<p>I can try to start that</p>



<a name="197564682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197564682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197564682">(May 14 2020 at 14:40)</a>:</h4>
<p>yes, that seems the best approach</p>



<a name="197566053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197566053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197566053">(May 14 2020 at 14:50)</a>:</h4>
<p>Score one for MCP :)</p>



<a name="197566068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197566068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197566068">(May 14 2020 at 14:50)</a>:</h4>
<p>(This seems to have been a productive design conversation)</p>



<a name="197568432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197568432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197568432">(May 14 2020 at 15:05)</a>:</h4>
<p><span aria-label="clap" class="emoji emoji-1f44f" role="img" title="clap">:clap:</span> <span aria-label="clap" class="emoji emoji-1f44f" role="img" title="clap">:clap:</span> <span aria-label="clap" class="emoji emoji-1f44f" role="img" title="clap">:clap:</span></p>



<a name="197573788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197573788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197573788">(May 14 2020 at 15:38)</a>:</h4>
<p>agreed! I like this structured way. Instead of just bumping ideas between everyone with no clear picture, this kinda forces us to have the same mental picture</p>



<a name="197591372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591372">(May 14 2020 at 17:41)</a>:</h4>
<p>hackmd where I am writing up a brief MCP details: <a href="https://hackmd.io/ra2JEG69R1qAeWFEGK_T-w">https://hackmd.io/ra2JEG69R1qAeWFEGK_T-w</a></p>



<a name="197591601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591601">(May 14 2020 at 17:43)</a>:</h4>
<p>Some complexities:</p>
<p>If you want to rewrite something like <code>&amp;&lt;place&gt;</code>, it's easy enough to add intermediate borrows</p>



<a name="197591645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591645">(May 14 2020 at 17:43)</a>:</h4>
<p>But if you are doing a <em>move</em>, and that move is passing through a <code>Box</code>, what do you us for the intermediate pointer type?</p>



<a name="197591778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591778">(May 14 2020 at 17:44)</a>:</h4>
<p>Or should we simply recommend writing <code>some_op(P)</code> (where <code>P</code> is a complex place) to </p>
<div class="codehilite"><pre><span></span><code>let tmp = move P;
some_op(tmp)
</code></pre></div>


<p>i.e., we limit complex places to the simple case of a <code>move place</code> operation?</p>



<a name="197591818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591818">(May 14 2020 at 17:44)</a>:</h4>
<p>ps, <span class="user-mention" data-user-id="120791">@RalfJ</span>, regarding the naming of <code>Rvalue</code>, it felt very unnatural to write <code>Value</code> (or "value expression") in the above sentence... operation felt much more natural :)</p>



<a name="197591873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591873">(May 14 2020 at 17:45)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>, <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> thoughts?</p>



<a name="197591939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197591939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197591939">(May 14 2020 at 17:45)</a>:</h4>
<p>Similarly, is it worth simplifying borrows? Or should we just say that the only place a "complex" place can appear is in borrows/moves?</p>



<a name="197592092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197592092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197592092">(May 14 2020 at 17:47)</a>:</h4>
<p>(I suppose that we could even do that during <em>construction</em> ... in fact, we probably almost do...)</p>



<a name="197592123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197592123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197592123">(May 14 2020 at 17:47)</a>:</h4>
<p>anyway, I'm going to stop typing now but feel free to edit <a href="https://hackmd.io/ra2JEG69R1qAeWFEGK_T-w">the hackmd</a> here</p>



<a name="197592881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197592881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197592881">(May 14 2020 at 17:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197591818">said</a>:</p>
<blockquote>
<p>ps, <span class="user-mention silent" data-user-id="120791">RalfJ</span>, regarding the naming of <code>Rvalue</code>, it felt very unnatural to write <code>Value</code> (or "value expression") in the above sentence... operation felt much more natural :)</p>
</blockquote>
<p>"<code>move place</code>" expression" feels natural though, doesn't it?</p>



<a name="197592966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197592966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197592966">(May 14 2020 at 17:53)</a>:</h4>
<p>So one possible downside that should be discussed is that if you have a type like <code>[BigStruct; 20]</code> and want to get a field of a single struct in the array, the current scheme lets you do:</p>
<div class="codehilite"><pre><span></span><code>field = (arr[idx]).x
</code></pre></div>


<p>But if you separate out index projections, you have to do one of</p>
<div class="codehilite"><pre><span></span><code>tmp = arr[idx]  // Creates a large temporary on the stack
field = tmp.x
</code></pre></div>


<p>or</p>
<div class="codehilite"><pre><span></span><code>tptr = &amp;arr[idx] // Bad for our simple form of alias analysis
fptr = &amp;tptr.x
field = *fptr
</code></pre></div>


<p>How would we address this issue? Or are we not worried about it? Also cc <span class="user-mention" data-user-id="124289">@Hanna Kruppe</span>  and <span class="user-mention" data-user-id="133247">@bjorn3</span>, who I'm sure are better able to explain these kinds of concerns than I am.</p>



<a name="197592984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197592984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197592984">(May 14 2020 at 17:53)</a>:</h4>
<p>(FWIW I wasnt the one proposing "value" for this, precisely because it is getting awkward here. I got outvoted though... including by <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I believe :D )</p>



<a name="197593118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197593118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197593118">(May 14 2020 at 17:54)</a>:</h4>
<p>a "post borrowck lowering" proposal has the problem that the invariants enforced by the lowering are not encoded in the types</p>



<a name="197598365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598365">(May 14 2020 at 18:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197592984">said</a>:</p>
<blockquote>
<p>(FWIW I wasnt the one proposing "value" for this, precisely because it is getting awkward here. I got outvoted though... including by <span class="user-mention silent" data-user-id="116009">nikomatsakis</span> I believe :D )</p>
</blockquote>
<p>wait what. I wanted "expression". oh I can't remember.</p>



<a name="197598371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598371">(May 14 2020 at 18:31)</a>:</h4>
<p>I thought eddyb wanted "op"?</p>



<a name="197598373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598373">(May 14 2020 at 18:31)</a>:</h4>
<p>anyway</p>



<a name="197598423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598423">(May 14 2020 at 18:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197593118">said</a>:</p>
<blockquote>
<p>a "post borrowck lowering" proposal has the problem that the invariants enforced by the lowering are not encoded in the types</p>
</blockquote>
<p>say more?</p>



<a name="197598467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598467">(May 14 2020 at 18:32)</a>:</h4>
<p>oh, you mean the MIR types?</p>



<a name="197598513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598513">(May 14 2020 at 18:32)</a>:</h4>
<p>this is true, but I don't think it matters that much. that's just life</p>



<a name="197598541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598541">(May 14 2020 at 18:32)</a>:</h4>
<p>i.e., we also split critical edges and so forth and that's not encoded</p>



<a name="197598583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598583">(May 14 2020 at 18:33)</a>:</h4>
<p>but I DO think this is going further down the road of saying "there are two IRs packed into one here" -- or at least there is an important <em>subset</em></p>



<a name="197598608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197598608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197598608">(May 14 2020 at 18:33)</a>:</h4>
<p>I guess it's a drag that we have to <code>assert</code> for invalid enum variants, that is true</p>



<a name="197599065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197599065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197599065">(May 14 2020 at 18:36)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> clearly moving onto the stack is both incorrect and ineffecient. </p>
<p>I think there are two options for <code>arr[idx].x</code>, either you do</p>
<div class="codehilite"><pre><span></span><code>tmp = move arr[idx].x // complex places only allowed in this kind of op, but they can be arbitrarily complex
</code></pre></div>


<p>or you do some variant of</p>
<div class="codehilite"><pre><span></span><code>tmp1 = &amp;arr[idx]
tmp2 = &amp;tmp1.x
data = *tmp2
</code></pre></div>


<p>What did you mean by "bad for our simple form of alias analysis?" My main worry there is that moves out of references aren't allowed. Though maybe  the <code>&amp;</code> has semantic meaning for stacked borrows that may be problematic for later moves? (I think we decided it is ok for stacked borrows, but I'd want to check)</p>



<a name="197599721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197599721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197599721">(May 14 2020 at 18:41)</a>:</h4>
<p>Right, I suppose I was only considering <code>Copy</code> types.</p>
<p>In the generator transform for example. As soon as something be comes borrowed, we have to assume that it requires storage across yield points. If we lower to the second form, <code>arr</code> would now require storage.</p>



<a name="197600513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197600513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197600513">(May 14 2020 at 18:46)</a>:</h4>
<p>To be more concrete:</p>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">arr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="n">BigStruct</span>::<span class="n">new</span><span class="p">();</span><span class="w"> </span><span class="mi">42</span><span class="p">];</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">arr</span><span class="p">[</span><span class="mi">10</span><span class="p">].</span><span class="n">field</span><span class="p">;</span><span class="w"> </span><span class="c1">// After lowering, creates a reference to `arr`</span>
<span class="kr">yield</span><span class="p">;</span><span class="w"> </span><span class="c1">// borrowed locals need to live across yield points</span>
</code></pre></div>



<a name="197600830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197600830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197600830">(May 14 2020 at 18:48)</a>:</h4>
<p>I suppose this isn't a problem if we put the <code>StorageDead</code> for <code>arr</code> in the right place, above the yield point.</p>



<a name="197601003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601003">(May 14 2020 at 18:49)</a>:</h4>
<p>(if we use <code>arr</code> below the yield point, we have to store it regardless of whether it is borrowed, which I didn't realize at first)</p>



<a name="197601184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601184">(May 14 2020 at 18:51)</a>:</h4>
<p>In any case, I'm mildly skeptical of a change that relies on creating more short-lived references or pointers, although I think this could be mitigated with the addition of an <code>InvalidateBorrows</code> statement.</p>



<a name="197601642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601642">(May 14 2020 at 18:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197599721">said</a>:</p>
<blockquote>
<p>In the generator transform for example. As soon as something be comes borrowed, we have to assume that it requires storage across yield points. If we lower to the second form, <code>arr</code> would now require storage.</p>
</blockquote>
<p>I see. We would have to make that smarter, yes.</p>



<a name="197601672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601672">(May 14 2020 at 18:54)</a>:</h4>
<p>I mean basically the whole <em>point</em> of this change is to create intermediate pointers.</p>



<a name="197601691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601691">(May 14 2020 at 18:54)</a>:</h4>
<p>On the premise that today's places are too complex.</p>



<a name="197601721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601721">(May 14 2020 at 18:54)</a>:</h4>
<p>That said, the variant I listed of "limiting complex places to a single form of statement" has none of these problems</p>



<a name="197601736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197601736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197601736">(May 14 2020 at 18:54)</a>:</h4>
<p>but maybe it doesn't actually <em>solve</em> any problems either</p>



<a name="197603142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197603142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197603142">(May 14 2020 at 19:05)</a>:</h4>
<p>That's true, but as you allude to, MIR optimizations will still have to handle complex places even if they are limited to a single statement kind.</p>



<a name="197603663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197603663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197603663">(May 14 2020 at 19:09)</a>:</h4>
<p>I feel like I'm being too pessimistic here. I certainly see the upsides, and would very much like to not think about derefs and variable array indices when writing MIR optimizations. I just don't have a good idea of whether the upsides outweigh the (potential) downsides enough to justify what I think would be a rather large refactoring, even if we don't have to touch the borrow checker. Maybe I'm just being irrationally averse to change though? I'd like to hear what others with more experience think about this, since no constructive alternatives are coming to mind.</p>



<a name="197621953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197621953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197621953">(May 14 2020 at 21:41)</a>:</h4>
<p>I'm just as happy to leave it as is :P I guess we would need to discuss with <span class="user-mention" data-user-id="119009">@eddyb</span> what the full benefits were that they wanted to get</p>



<a name="197622922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197622922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197622922">(May 14 2020 at 21:50)</a>:</h4>
<p>Now that the visitor has been fixed to take index projections into account, and most of the special cases were removed, this might be a too invasive and time-consuming change to be worth it in the end.</p>



<a name="197785399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197785399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197785399">(May 16 2020 at 08:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291/near/197601691">said</a>:</p>
<blockquote>
<p>On the premise that today's places are too complex.</p>
</blockquote>
<p>(place expressions <span aria-label="rofl" class="emoji emoji-1f923" role="img" title="rofl">:rofl:</span> ... I'm only partially joking though, the thing place expressions evaluate to -- what I think when I hear "place" -- isn#t affected by this change)</p>



<a name="197791988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197791988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197791988">(May 16 2020 at 11:48)</a>:</h4>
<p>on the other hand, doing such a change might have prevented <a href="https://github.com/rust-lang/rust/pull/61559/files#r426146600">what I think is a soundness bug</a>... our <code>visit_place</code> method does not actually visit every place any more since some are just implicitly encoded as prefixes of the chain of projections!</p>



<a name="197793725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197793725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197793725">(May 16 2020 at 12:34)</a>:</h4>
<p>looks like <code>visit_projection_elem</code> can be used to visit every sub-place, but it doesnt give you a <code>Place</code> so that's rather inconvenient and also it only exists for read-only visitors? <br>
Also, <code>ProjectionElem::Field</code> is visited with <code>visit_ty</code> only on read-only visitors? That's odd.</p>



<a name="197793734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197793734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197793734">(May 16 2020 at 12:34)</a>:</h4>
<p>are these <code>process_*</code> methods in the visitor meant to be overwritten or not?</p>



<a name="197794590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197794590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197794590">(May 16 2020 at 12:57)</a>:</h4>
<p>oh the check is actually correct I think, it's just not necessary to have it in the loop</p>



<a name="197794598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197794598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197794598">(May 16 2020 at 12:58)</a>:</h4>
<p>but actually visiting each "sub-place" seems hard now?</p>



<a name="197951229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197951229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197951229">(May 18 2020 at 15:29)</a>:</h4>
<p>(Re: place expressions, indeed the distinction can be confusing, and the "expression" suffix is kind of long and clumsy, one of the reasons I wanted to use the term "path" to mean "place expression", so we could be precise...but let's not rehash it, though I'll note that also in your comments you mostly wrote "place" and not "place expression")</p>



<a name="197951293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Virtual%20locals%20scheme%20compiler-team%23291/near/197951293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Virtual.20locals.20scheme.20compiler-team.23291.html#197951293">(May 18 2020 at 15:29)</a>:</h4>
<p>As for the visitor setup, I'm not sure how it ended up, but I do remember it was a bit difficult to figure out the right setup given interning</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>